<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form action="index.html">
      <input type="submit" value="提交" />
    </form>
    <script>
      var form = document.querySelector("form");
      // 给表单注册 onsubmit事件 当表单提交时
      //   form.addEventListener("submit", function () {
      //     console.log("表单提交");
      //     // e.preventDefault();

      //     return false;
      //   });

      form.onsubmit = function () {
        console.log("表单提交");
        return false;
      };
    </script>
  </body>
</html>
